//banner图
var $hd = $('.hd')
var $bd = $('.bd')
var $bdli = $('.bd li')
var $hdli=$('.hd li')
var left = ($bd.outerWidth()-$hd.outerWidth())/2+"px"
$hd.css({'left':left,'visibility':'visible'})
function tog(time=5000) {
    let timer=setInterval(()=>{
        $bdli.fadeToggle(1000)
        $hdli.toggleClass("light")
    },time)
    return timer
}
var timer=tog()
$hdli.mousedown((event)=>{
    event = event || window.event
    let flag=event.target.innerHTML-1
    let isLight=$hdli[flag].className
    clearInterval(timer)
    if(!isLight){
        $bdli.fadeToggle(1000)
        $hdli.toggleClass("light")
    }
})
$hdli.mouseup(()=>{
    timer=tog()
})
//banner导航的小三角显隐
var $ban_nav_li=$('#banner_nav li')
$ban_nav_li.mouseover((event)=>{
    event = event || window.event
    let flag=$(event.currentTarget).attr("flag")
    let $li=$(`#nav_detail li:eq(${flag})`)
    $li.removeClass("hidden")
    $(event.currentTarget).addClass("ang")
})
$ban_nav_li.mouseleave((event)=>{
    event = event || window.event
    let flag=$(event.currentTarget).attr("flag")
    let $li=$(`#nav_detail li:eq(${flag})`)
    $li.addClass("hidden")
    $(event.currentTarget).removeClass("ang")
})
var $detail = $('#nav_detail li')
$detail.mouseover((event)=>{
    event = event || window.event
    $(event.currentTarget).removeClass("hidden")
    let flag=$(event.currentTarget).attr("flag")
    let $li=$(`#banner_nav li:eq(${flag})`)
    $li.addClass("ang")
})
$detail.mouseleave((event)=>{
    $(event.currentTarget).addClass("hidden")
    let flag=$(event.currentTarget).attr("flag")
    let $li=$(`#banner_nav li:eq(${flag})`)
    $li.removeClass("ang")
})
//让脚印亮起来
var $item=$('.goods_item')
$item.mouseover((event)=>{
    event.currentTarget.children[0].style.background="url('../bd.png') -32px -16px"
})
$item.mouseleave((event)=>{
    event.currentTarget.children[0].style.background="url('../bd.png') 0px -16px"
})